cars = ['audi', 'bmw', 'subaru', 'toyota']
cars.reverse()
for car in cars:
    if car == 'bmw':
        print(car.upper())
    else:
        print(car.lower())
print("========================")

car = 'Audi'
print(car == 'audi')
print(car.lower() == 'audi')
print("========================")

age_0 = 22
age_1 = 18
result = age_0 >= 21 and age_1 >= 21
print(result)
result = age_0 >= 21 or age_1 >= 21
print(result)
print("========================")

banned_users = ['andrew', 'carolina', 'david']
user = 'marie'
if user not in banned_users:
    print(user.title() + ", you can post a response if you wish.")
print("========================")

age = 12
if age < 4:
    print("Your admission cost is $0.")
elif age < 18:
    print("Your admission cost is $5.")
else:
    print("Your admission cost is $10.")
print("========================")

requested_toppings = ['mushrooms', 'green peppers', 'extra cheese']

for requested_topping in requested_toppings:
    if requested_topping == 'green peppers':
        print("Sorry, we are out of green peppers right now.")
    else:
        print("Adding " + requested_topping + ".")
print("\nFinished making your pizza!")
print("========================")

requested_toppings = []
if requested_toppings:
    for requested_topping in requested_toppings:
        print("Adding " + requested_topping + ".")
    print("\nFinished making your pizza!")
else:
    print("Are you sure you want a plain pizza?")
print("========================")

available_toppings = ['mushrooms', 'olives', 'green peppers',
                      'pepperoni', 'pineapple', 'extra cheese']
requested_toppings = ['mushrooms', 'french fries', 'extra cheese']
for requested_topping in requested_toppings:
    if requested_topping in available_toppings:
        print("Adding " + requested_topping + ".")
    else:
        print("Sorry, we don't have " + requested_topping + ".")
print("\nFinished making your pizza!")
print("========================")

aliens_0 = {'color': 'red', 'pointer': 5}
print(aliens_0['color'])
print(aliens_0['pointer'])
print("========================")

alien_0 = {'color': 'green', 'points': 5}
print(alien_0)
alien_0['x_position'] = 0
alien_0['y_position'] = 25
print(alien_0)
print("========================")

alien_0 = {'color': 'yellow'}
print(alien_0['color'])
print("========================")

alien_0 = {'color': 'green', 'points': 5}
del alien_0['points']
print(alien_0)
print("========================")

# 遍历字典中的所有的键值对
user_0 = {
    'username': 'efermi',
    'first': 'enrico',
    'last': 'fermi',
}
for key, value in user_0.items():
    print("key = " + key)
    print("value = " + value)
print("========================")

favorite_languages = {
    'jen': 'python',
    'sarah': 'c',
    'edward': 'ruby',
    'phil': 'python',
}
for name in favorite_languages:
    print("name is " + name)
print("------------------------")
for name in favorite_languages.keys():
    print("name is " + name)
print("------------------------")
for name in sorted(favorite_languages.keys()):
    print("name is " + name)
print("========================")

favorite_languages = {
    'jen': 'python',
    'sarah': 'c',
    'edward': 'ruby',
    'phil': 'python',
}
for value in favorite_languages.values():
    print("value is " + value)
    print("name is " + name)
print("========================")

alien_0 = {'color': 'green', 'points': 5}
alien_1 = {'color': 'yellow', 'points': 10}
alien_2 = {'color': 'red', 'points': 15}
aliens = [alien_0, alien_1, alien_2]
for alien in aliens:
    print(alien)
print("========================")

aliens = []
for alien_number in range(10):
    new_alien = {'color': 'green', 'points': 5, 'speed': 'slow'}
    aliens.append(new_alien)

for alien in aliens[:5]:
    print(alien)
print("Total number of aliens: " + str(len(aliens)))
print("========================")

favorite_languages = {
    'jen': ['python', 'ruby'],
    'sarah': ['c'],
    'edward': ['ruby', 'go'],
    'phil': ['python', 'haskell'],
}

count = 0
for name, languages in favorite_languages.items():
    print(name.title() + "'s favorite languages are:")
    count += 1
    for language in languages:
        print(language.title())
    if count < len(favorite_languages):
        print("------------------------")
print("========================")

# 复杂的数据字典
users = {
    'aeinstein': {
        'first': 'albert',
        'last': 'einstein',
        'location': 'princeton',
    },
    'mcurie': {
        'first': 'marie',
        'last': 'curie',
        'location': 'paris',
    }
}

for username, user_info in users.items():
    print("Username: " + username)
    full_name = user_info['first'] + " " + user_info['last']
    location = user_info['location']
    print("Full name: " + full_name.title())
    print("Location: " + location.title())
    print("------------------------")
print("========================")

# message = input("Tell me something, and I will repeat it back to you: ")
# print(message)

# age = input("How old are you? ")
# print(age)
print("========================")

# height = input("How tall are you, in inches? ")
# height = int(height)
#
# if height >= 36:
#     print("\nYou're tall enough to ride!")
# else:
#     print("\nYou'll be able to ride when you're a little older.")
print("========================")

current_number = 1
while current_number <= 5:
    print(current_number)
    current_number += 1
print("========================")

# prompt = "\nTell me something, and I will repeat it back to you:"
# prompt += "\nEnter 'quit' to end the program. "
# message = ""
#
# while message != 'quit':
#     message = input(prompt)
#     print(message)
print("========================")

# prompt = "\nPlease enter the name of a city you have visited:"
# prompt += "\n(Enter 'quit' when you are finished.) "
#
# while True:
#     city = input(prompt)
#     if city == 'quit':
#         break
#     else:
#         print("I'd love to go to " + city.title() + "!")
print("========================")

current_number = 0

while current_number < 10:
    current_number += 1
    if current_number % 2 == 0:
        continue
    print(current_number)
print("========================")

# 首先，创建一个待验证用户列表
# 和一个用于存储已验证用户的空列表
unconfirmed_users = ['alice', 'brian', 'candace']
confirmed_users = []

# 验证每个用户，直到没有未验证用户为止
# 将每个经过验证的列表都移到已验证用户列表中
while unconfirmed_users:
    current_user = unconfirmed_users.pop()
    print("Verifying user: " + current_user.title())
    confirmed_users.append(current_user)

# 显示所有已验证的用户
print("\nThe following users have been confirmed:")
for confirmed_user in confirmed_users:
    print("userName: " + confirmed_user.title())
print("========================")

# responses = {}
#
# # 设置一个标志，指出调查是否继续
# polling_active = True
# while polling_active:
#     # 提示输入被调查者的名字和回答
#     name = input("\nWhat is your name? ")
#     response = input("Which mountain would you like to climb someday? ")
#     # 将答卷存储在字典中
#     responses[name] = response
#     # 看看是否还有人要参与调查
#     repeat = input("Would you like to let another person respond? (yes/ no) ")
#     if repeat == 'no':
#         polling_active = False
#
# # 调查结束，显示结果
# print("\n--- Poll Results ---")
# for name, response in responses.items():
#     print(name + " would like to climb " + response + ".")
print("========================")
